/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package test;

import javax.sound.midi.MidiChannel;
import javax.sound.midi.MidiDevice;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Synthesizer;

/**
 *
 * @author Kyle
 */
public class Main {
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        MidiDevice.Info[] devices = MidiSystem.getMidiDeviceInfo();
        System.out.println("Possible Devices:");
        for(int x = 0; x < devices.length; x++){
            System.out.println(devices[x].getName()+"\n\t"+devices[x].getDescription());
        }
        Synthesizer synth;
        MidiChannel[] channels;
        try {
            synth = MidiSystem.getSynthesizer();
            synth.open();
            channels = synth.getChannels();
            channels[0].programChange(1);
            System.out.println("Testing sound...");
            channels[0].noteOn(60, 100);
            Thread.sleep(1000);
            channels[0].allNotesOff();
            synth.close();
        } catch (MidiUnavailableException ex) {
            System.out.println("ERROR: Midi device unavailable...");
            System.exit(0);
        } catch (InterruptedException e){

        }
    }
}
